package com.hontech.pastacooking.activity.window

import android.view.View
import android.widget.Button
import android.widget.TextView
import com.hontech.pastacooking.R
import com.hontech.pastacooking.app.dimenById
import com.hontech.pastacooking.conn.HeaterParam
import com.hontech.pastacooking.utils.S

private val width = dimenById(R.dimen.x500)
private val height = dimenById(R.dimen.y500)

class HeaterParamWindow : MoveableWindow(R.layout.window_heater_param, width, height) {

    private val btnClose = view.findViewById<Button>(R.id.id_btn_close)

    private val tvWaterTemp = view.findViewById<TextView>(R.id.id_tv_water_temp)
    private val tvWaterTimeout = view.findViewById<TextView>(R.id.id_tv_water_timeout)
    private val tvSteamTemp = view.findViewById<TextView>(R.id.id_tv_steam_temp)
    private val tvSteamKpa = view.findViewById<TextView>(R.id.id_tv_steam_kpa)
    private val tvSteamTimeout = view.findViewById<TextView>(R.id.id_tv_steam_timeout)
    private val tvDrawWaterTimeout = view.findViewById<TextView>(R.id.id_tv_draw_water_timeout)
    private val tvDrawSteamTimeout = view.findViewById<TextView>(R.id.id_tv_draw_steam_timeout)
    private val tvFlow = view.findViewById<TextView>(R.id.id_tv_flow)
    private val tvMiniWeight = view.findViewById<TextView>(R.id.id_tv_mini_weight)

    init {
        btnClose.setOnClickListener { dismiss() }
    }

    fun show(parent: View, param: HeaterParam) {
        tvWaterTemp.text = "${param.waterTemp}℃"
        tvWaterTimeout.text = "${param.waterTimeout}${S.t143}"
        tvSteamTemp.text = "${param.steamTemp}℃"
        tvSteamKpa.text = "${param.steamKpa}KPA"
        tvSteamTimeout.text = "${param.steamTimeout}${S.t143}"
        tvDrawWaterTimeout.text = "${param.drawWaterTimeout}${S.t143}"
        tvDrawSteamTimeout.text = "${param.drawSteamTimeout}${S.t143}"
        tvFlow.text = "${param.flow}${S.t144}"
        tvMiniWeight.text = "${param.miniBucketWeight}g"
        show(parent)
    }
}

fun showHeaterPram(parent: View, param: HeaterParam) {
    val w = HeaterParamWindow()
    w.show(parent, param)
}


